home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_005 / mandelbrotsrc / mand4.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  13KB  |  296 lines

  1.  
  2. /* ***************************************************************************
  3.  *                     MAND4.C - Information
  4.  *             Mandelbrot Self-Squared Dragon Generator
  5.  *                    For the Commodore Amiga
  6.  *                         Version 2.01
  7.  *
  8.  *              Copyright (C) 1986,  =Robert J. Mical=
  9.  *                   Placed in the Public Domain
  10.  *
  11.  *
  12.  *   This program may be distributed free of charge as long as the above
  13.  *                         notice is retained.
  14.  *
  15.  ************************************************************************** */
  16.  
  17. /* === IMPORTANT NOTE: =================================================
  18.  *   If you are going to design Information pages, make sure that all
  19.  *   lines are a maximum of 59 characters long.  Also, make sure that
  20.  *   there are 19 lines at most per page.  These two restrictions
  21.  *   are to allow info pages to fit on low-res fat font screens.
  22.  *   These two restrictions combined comprise the reason why the info 
  23.  *   pages are (and should remain) terse.
  24.  * ===================================================================== */
  25.  
  26.  
  27. #include "mand.h"
  28.  
  29. extern SHORT Color0, Color1, Color2;
  30. extern SHORT UserPalette[29];
  31.  
  32. extern FILE *console;
  33. extern float cnvf();
  34.  
  35. extern union kludge {
  36.    float f;
  37.    int i;
  38. } start_r,end_r,start_i,end_i;  /* Block bounds for set */
  39. extern int max_x,max_y,max_mem_y;  /* Graphics window size */
  40. extern int max_count,color_inc,color_offset,color_set,color_mode,color_div;
  41. extern int color_inset,func_num;
  42.  
  43. extern int v_starty,max_mem;
  44. extern long v_offset;
  45. extern UWORD *color_table,*v_mand_store;
  46.  
  47.  
  48. Information(page)
  49. SHORT page;
  50. {
  51.    FILE *c;
  52.  
  53.    c = console;
  54.  
  55.    switch (page) {
  56.  
  57. case 0:
  58. case 1:
  59. fprintf(c, "Mandelbrot Self-Squared Dragon Generator Version %s\n", VERSION);
  60. fputs("Copyright (C) 1985 - Robert S. French\n",c);
  61. fputs("Vastly Enhanced (with Intuition!) by  =RJ Mical=  1985/86\n",c);
  62. fputs("Copyright (C) 1986 - =Robert J. Mical= -\n",c);
  63. fputs("Placed in the public domain ... Please read and learn!\n",c);
  64. fputs("\n",c);
  65. fputs("Inspired by Scientific American, August/1985\n",c);
  66. fputs("Corrections and improvements suggested by\n",c);
  67. fputs("\"The Fractal Geometry of Nature\"\n",c);
  68. fputs("By Benoit Mandelbrot, W.H. Freeman and Company, 1983\n",c);
  69. fputs("(Used to be Z=Z^2+C, now is Z=Z^2-u, etc.)\n",c);
  70. fputs("\n",c);
  71. fputs("Robert S. French may be contacted at:\n",c);
  72. fputs("   USPS:   2740 Frankfort Avenue\n",c);
  73. fputs("           Louisville, Ky  40206\n",c);
  74. fputs("   Phone: (502) 897-5096   ARPA: French#Robert%d@LLL-MFE\n",c);
  75. fputs("=RJ Mical= may be contacted at:\n",c);
  76. fputs("         Commodore-Amiga, Inc.\n",c);
  77. fputs("         983 University Avenue\n",c);
  78. fputs("         Los Gatos, CA  95030\n",c);
  79. break;
  80.  
  81. case 2:
  82. fputs("The four basic commands of this program are:\n",c);
  83. fputs("G  - Generate picture\n",c);
  84. fputs("   When this command is entered the Mandelbrot set is drawn\n",c);
  85. fputs("   according to the current settings.  When you first run\n",c);
  86. fputs("   this program, you can say \"G\" immediately and see \n",c);
  87. fputs("   the entire Mandelbrot set.\n",c);
  88. fputs("\n",c);
  89. fputs("SH   - Show current settings\n",c);
  90. fputs("   When you enter the command \"SH\", the current settings of\n",c);
  91. fputs("   all of the important variables are shown.  To reproduce\n",c);
  92. fputs("   a picture, you should copy these values down so you or\n",c);
  93. fputs("   anyone else can re-enter the values and re-generate\n",c);
  94. fputs("   the picture.\n",c);
  95. fputs("\n",c);
  96. fputs("I n  - Information pages\n",c);
  97. fputs("   Shows page n of the information pages.\n",c);
  98. fputs("\n",c);
  99. fputs("Q  - Quit\n",c);
  100. fputs("   Lets you exit back to the Workbench or CLI.\n",c);
  101. break;
  102.  
  103.  
  104. case 3:
  105. fputs("The Mandelbrot set consists of pairs of numbers, one number\n",c);
  106. fputs("real and the other complex.  This set can be graphed using\n",c);
  107. fputs("one axis for the real numbers and the other for the complex\n",c);
  108. fputs("numbers.  The Mandelbrot set is located on a graph roughly\n",c);
  109. fputs("centered over the origin (0,0).  The default settings of\n",c);
  110. fputs("this program create a display that shows the entire set.\n",c);
  111. fputs("All of the black display pixels represent Mandelbrot pairs.\n",c);
  112. fputs("The shaded pixels show the pairs that are *almost* in the\n",c);
  113. fputs("set.  The pairs nearest the set on the display just miss\n",c);
  114. fputs("making it into the set numerically; these are white.  The\n",c);
  115. fputs("more grey a position, the further the pair is from the set.\n",c);
  116. fputs("    This program lets you explore the Mandelbrot set by\n",c);
  117. fputs("panning across and zooming in to look at details of the set.\n",c);
  118. fputs("You can also change colors and display mode.  For instance:\n",c);
  119. fputs(" : CS 1      ; Use the fancy arrangements of color set 1\n",c);
  120. fputs(" : CO 29     ; Set the initial color offset\n",c);
  121. fputs(" : CI 4      ; Set the color increment\n",c);
  122. fputs(" : MC 29     ; Set the maximum tests count\n",c);
  123. fputs(" : G         ; Generate the picture\n",c);
  124. break;
  125.  
  126.  
  127. case 4:
  128. fputs("The MC command lets you specify how many times each position\n",c);
  129. fputs("is tested to see whether or not it's in the Mandelbrot set.\n",c);
  130. fputs("A low MC value means that very few tests will be done on\n",c);
  131. fputs("position, which will cause the display to be created more\n",c);
  132. fputs("quickly, but which will also have a cruder approximation of\n",c);
  133. fputs("the Mandelbrot set and, consequently, fewer colors.\n",c);
  134. fputs("\n",c);
  135. fputs("The MX and MY commands set the size of the display window.\n",c);
  136. fputs("The larger your window, the longer it takes for the picture\n",c);
  137. fputs("to be resolved.  While you're experimenting with the\n",c);
  138. fputs("program, you should create a smaller window with a lower\n",c);
  139. fputs("count value until you get approximately the picture that you\n",c);
  140. fputs("want to see.  Then when you've gotten a picture you want to\n",c);
  141. fputs("see in large scale, increase the size and count resolution\n",c);
  142. fputs("to see the detailed version of your picture.  For instance:\n",c);
  143. fputs(" : MC 8        ; Each position will be tested only 8 times\n",c);
  144. fputs(" : MX 80       ; The width is 25% of full width\n",c);
  145. fputs(" : MY 50       ; The height is 25% of full height\n",c);
  146. fputs(" : G           ; Generate the picture\n",c);
  147. break;
  148.  
  149. case 5:
  150. fputs(" : CS 1        ; Color set 1 (special ranges of colors)\n",c);
  151. fputs(" : CI 1        ; Color increment of 1 (smallest increment)\n",c);
  152. fputs(" : MC 29       ; Count position and number of colors\n",c);
  153. fputs("Then, by setting the initial color offset into color set 1 \n",c);
  154. fputs("using the command CO, you can select from these ranges:\n",c);
  155. fputs("      ======    ===========================================\n",c);
  156. fputs("        1-15    unit steps of blue\n",c);
  157. fputs("       16-30    unit steps of green\n",c);
  158. fputs("       31-45    unit steps of red\n",c);
  159. fputs("       46-60    unit steps of sky sky blue (blue and green)\n",c);
  160. fputs("       61-75    unit steps of purple (blue and red)\n",c);
  161. fputs("       76-90    unit steps of yellow (red and green)\n",c);
  162. fputs("       91-115   unit steps of white (all colors)\n",c);
  163. fputs("CM is the command to set the display mode.  Add up these:\n",c);
  164. fputs("    o  add 1 to get NO HOLD-AND-MODIFY\n",c);
  165. fputs("    o  add 2 to get INTERLACE\n",c);
  166. fputs("    o  add 4 to get HIRES (640 columns; low-res is 320)\n",c);
  167. fputs("For instance, for HIRES and NO HOLD-AND-MODIFY, add 1 + 4:\n",c);
  168. fputs(" : CM 5\n",c);
  169. break;
  170.  
  171. case 6:
  172. fputs("The starting (left) and ending (right) edge values for the\n",c);
  173. fputs("axis of the real numbers (the horizontal axis) can be set\n",c);
  174. fputs("using the commands SR (Start Real) and ER (End Real).  For\n",c);
  175. fputs("the complex numbers axis (vertical) the start (bottom) and\n",c);
  176. fputs("end (top) edge values are set using SI and EI.  Got it?\n",c);
  177. fputs("    The graph that you get with this program's default\n",c);
  178. fputs("values has the real numbers along the horizontal axis.  The\n",c);
  179. fputs("leftmost position represents the real number -2.85.  The\n",c);
  180. fputs("rightmost position represents 2.85.  The complex numbers\n",c);
  181. fputs("are charted along the vertical axis, starting at the bottom\n",c);
  182. fputs("with a value of -2.05 and ranging up to 2.05 at the top.\n",c);
  183. fputs("    You control the range of these axes using the text\n",c);
  184. fputs("commands SR, ER, SI and EI.  The commands ZR and ZI let you\n",c);
  185. fputs("zoom in or out on the real and imaginary axes respectively.\n",c);
  186. fputs("ZB lets you zoom on both proportionally.\n",c);
  187. fputs("    Once the display is built, there are ZOOM menu commands\n",c);
  188. fputs("which allow you to zoom in and out automatically.  These\n",c);
  189. fputs("are more convenient than using the text commands.  On the\n",c);
  190. fputs("other hand, the text commands lend precision.\n",c);
  191. break;
  192.  
  193. case 7:
  194. fputs("OK!  Now there's plenty of new features, especially being\n", c);
  195. fputs("able to change the colors and save pictures to the disk.\n", c);
  196. fputs("I hope you find this newest version more useable.  -=RJM=-\n", c);
  197. fputs("\n", c);
  198. fputs("There's lots more to this program than what's described on\n",c);
  199. fputs("these info pages.  You should read the available text on\n",c);
  200. fputs("Mandelbrot sets (see info page 1).  This program has more \n",c);
  201. fputs("features than what's described here.  If you can get your\n",c);
  202. fputs("hands on the source, you're welcome to expand these pages.\n",c);
  203. fputs("In fact, this program is still far from complete.  Care to\n",c);
  204. fputs("have a bash at it?  We need the greater-precision \n",c);
  205. fputs("floating point.  Also, we seriously need to be able to\n",c);
  206. fputs("save some or all of the image to a disk file in IFF format.\n",c);
  207. fputs("\n",c);
  208. fputs("Good luck.  Have fun!  Send mail (on USENET at least!) if\n",c);
  209. fputs("you find spectacular scenes.\n",c);
  210. break;
  211.  
  212.  
  213. default:
  214. fputs("SORRY:  there's not that many pages of info available!\n",c);
  215. AvailableCommands();
  216. break;
  217.  
  218.    }
  219.  
  220. }
  221.  
  222.  
  223. AvailableCommands()
  224. {
  225.     FILE *c;
  226.  
  227.     c = console;
  228.  
  229. /* === TRY TO KEEP THIS PAGE 18 LINES TALL AT MOST ======================== */
  230. fputs("AVAILABLE COMMANDS:\n",c);
  231. fputs("SH   - Show current settings        G  - Generate picture\n",c);
  232. fputs("I n  - Information pages            Q  - Quit\n",c);
  233. fputs("\n",c);
  234. fputs("SR n / SI n / ER n / EI n - Starting and ending coords\n",c);
  235. fputs("MX n / MY n - x/y display size      MC n - Max exam count\n",c);
  236. fputs("XR n / XI n - Move to new coordinates\n",c);
  237. fputs("ZR n / ZI n / ZB n - Zoom around the center point\n",c);
  238. fputs("\n",c);
  239. fputs("CM n - Graphics mode                F n - Dragon function\n",c);
  240. fputs("CI n - Color increment              CD  - Color divisor\n",c);
  241. fputs("CO n - Color offset                 CS  - Color set\n",c);
  242. fputs("CT n - Color for points in set      P n - Start from Preset\n",c);
  243. fputs("\n",c);
  244. fputs("D  - Display picture                A  - Analyze\n",c);
  245. fputs("SA filename - Save set data         L name - Load set data\n",c);
  246. fputs("< filename - Redirect input         ; string - Comment\n",c);
  247. fprintf(c,"MM n - Maximum number of %d pixel lines in memory\n",MAXX);
  248.  
  249. }
  250.  
  251.  
  252. CurrentSettings()
  253. {
  254. SHORT i, c;
  255.  
  256. fprintf(console, "             Description  Command  Current Value\n");
  257. fprintf(console, "========================  =======  =============\n");
  258. fprintf(console, "       Start Real (Left)   SR n:   %f\n", cnvf(start_r.i));
  259. fprintf(console, "        End Real (Right)   ER n:   %f\n", cnvf(end_r.i));
  260. fprintf(console, "Start Imaginary (Bottom)   SI n:   %f\n", cnvf(start_i.i));
  261. fprintf(console, "     End Imaginary (Top)   EI n:   %f\n", cnvf(end_i.i));
  262. fputs("\n", console);
  263.  
  264. fprintf(console, "          Function Number   F n:   %d\n", func_num);
  265. fprintf(console, "   Max Examination Count   MC n:   %d\n", max_count);
  266. fprintf(console, "               Color Set   CS n:   %d\n", color_set);
  267. if (color_set < 2)
  268.   {
  269.   fprintf(console, "         Color Increment   CI n:   %d\n", color_inc);
  270.   fprintf(console, "            Color Offset   CO n:   %d\n", color_offset);
  271.   }
  272. else
  273.   for (i = 0; i < 32; i++)
  274.     {
  275.     if ((i % 6) == 0) fputs("Color ", console);
  276.  
  277.     switch (i)
  278.         {
  279.         case 0: c = Color0; break;
  280.         case 1: c = Color1; break;
  281.         case 2: c = Color2; break;
  282.         default: c = UserPalette[i - 3]; break;
  283.         }
  284.  
  285.     fprintf(console, "%d=%d,%d,%d ", i, (c>>8) & 0xF, (c>>4) & 0xF, c & 0xF);
  286.     if ((i % 6) == 5) fputs("\n", console);
  287.     }
  288.  
  289. fputs("\n", console);
  290. fprintf(console, "              Color Mode   CM n:   %d\n", color_mode);
  291. fprintf(console, "           Color Divisor   CD n:   %d\n", color_div);
  292. fprintf(console, "  Display Width/Height   MX/Y n:   %d %d\n", max_x, max_y);
  293. }
  294.  
  295.  
  296.